<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>message</title>
  <style>
    html,
    body {
      margin: 0;
      padding: 0;
      height: 100%;
      background-color: rgba(0, 0, 0, .5);
    }
  </style>
</head>

<body>
  <button>打开子窗口向夫窗口传递信息</button>
  <span class="span"></span>
</body>
<script>
  "use strict";
  let but = document.querySelector("button");
  but.addEventListener("click", async () => {
    window.open("../open/open.html", "message",
      "height=300,width=400,top=200,left=200,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no"
    );
    window.addEventListener("message", async (res) => {
      document.querySelector(".span").innerHTML = res.data;
    });
  });
</script>

</html>